package org.hagen.mmia.yars.collection;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;

public class Topic {

	private String 		need 	= null;	
	public  Set<String> relSet 	= null;
	
	public  String	 	ID;
	public  int		 	index;
	
	public void print() {
		System.out.println( "number : " + ID );
		System.out.println( "need  : "  + need );
		System.out.println( "*******************" );
	}
	
	public Topic( int index, String ID ) {
		this.index = index;
		this.ID    = ID;
		
		need 	  = new String();
		relSet    = new HashSet<String>();
	}
	
	public void setNeed( String need ) {
		this.need = need;
	}
	
	public String getNeed() {
		return need;
	}
	
	public void appendNeed( String line ) {
		need += line + " ";
	}	
	
	public int getDistinctTermCount() {

		String[] words = need.split("\\s+");

		ArrayList<String> list = new ArrayList<String>();

		for( int i=0; i<words.length; i++ ) {
				
			if( ! list.contains( words[i] ) )
				list.add( words[i] );
		}
		
		return list.size();
	}	
}
